package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.HyHouseMajordomo;
import com.ruoyi.system.service.IHyHouseMajordomoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 管家设置Controller
 * 
 * @author wangjiangbo
 * @date 2025-01-10
 */
@RestController
@RequestMapping("/majordomo")
public class HyHouseMajordomoController extends BaseController
{
    @Autowired
    private IHyHouseMajordomoService hyHouseMajordomoService;

    /**
     * 查询管家设置列表
     */
    @RequiresPermissions("guanjia:majordomo:list")
    @GetMapping("/list")
    public TableDataInfo list(HyHouseMajordomo hyHouseMajordomo)
    {
        startPage();
        List<HyHouseMajordomo> list = hyHouseMajordomoService.selectHyHouseMajordomoList(hyHouseMajordomo);
        return getDataTable(list);
    }

    /**
     * 导出管家设置列表
     */
    @RequiresPermissions("guanjia:majordomo:export")
    @Log(title = "管家设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HyHouseMajordomo hyHouseMajordomo)
    {
        List<HyHouseMajordomo> list = hyHouseMajordomoService.selectHyHouseMajordomoList(hyHouseMajordomo);
        ExcelUtil<HyHouseMajordomo> util = new ExcelUtil<HyHouseMajordomo>(HyHouseMajordomo.class);
        util.exportExcel(response, list, "管家设置数据");
    }

    /**
     * 获取管家设置详细信息
     */
    @RequiresPermissions("guanjia:majordomo:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hyHouseMajordomoService.selectHyHouseMajordomoById(id));
    }

    /**
     * 新增管家设置
     */
    @RequiresPermissions("guanjia:majordomo:add")
    @Log(title = "管家设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HyHouseMajordomo hyHouseMajordomo)
    {
        return toAjax(hyHouseMajordomoService.insertHyHouseMajordomo(hyHouseMajordomo));
    }

    /**
     * 修改管家设置
     */
    @RequiresPermissions("guanjia:majordomo:edit")
    @Log(title = "管家设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HyHouseMajordomo hyHouseMajordomo)
    {
        return toAjax(hyHouseMajordomoService.updateHyHouseMajordomo(hyHouseMajordomo));
    }

    /**
     * 删除管家设置
     */
    @RequiresPermissions("guanjia:majordomo:remove")
    @Log(title = "管家设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hyHouseMajordomoService.deleteHyHouseMajordomoByIds(ids));
    }
}
